$('#loginButton').click(function (event) {
    event.preventDefault();
    var readId = $('#inputreadID').val();
    var password = $('#inputPassword').val();
    var captcha = $('#inputCaptcha').val();
    if (readId === "" || password === "") {
        alert("账户或密码不能为空");
        return false;
    }else if(captcha === "")
    {
        alert("验证码不能为空");
        return false;
    }
    else{
        $.ajax({
            type: 'POST',
            url: '/reader/login',
            contentType: 'application/x-www-form-urlencoded',
            data: { readId: readId, password: password, captcha: captcha},
            success: function (response) {
                if (response === '1') {
                    alert('账户不存在');
                } else if (response === '2') {
                    alert('登陆成功');
                    window.location.href = "./readerIndex"
                } else if (response === '3') {
                    alert('密码错误');
                } else if (response === '4') {
                    alert('验证码错误');
                }
                else {
                    alert('未知的返回结果，请联系管理员！');
                }
            },
            error: function () {
                alert('请求发生错误，请稍后再试！');
            }
        });
    }
});